package org.springblade.third.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class ThirdResponse<T> {

    @Schema(description = "是否成功")
    private boolean success;

    @Schema(description = "错误码")
    private String code;

    @Schema(description = "错误描述或成功提示")
    private String message;

	/**
	 * 统一处理所有数据源请求结果状态
	 * 统一处理所有数据源请求结果信息
	 * 返回数据源的原始数据
	 */
	@Schema(description = "数据载荷")
    private T data;

    public static <T> ThirdResponse<T> ok(T data) {
        ThirdResponse<T> r = new ThirdResponse<>();
        r.success = true;
        r.data = data;
        r.code = "0";
        r.message = "OK";
        return r;
    }

    public static <T> ThirdResponse<T> fail(String code, String message) {
        ThirdResponse<T> r = new ThirdResponse<>();
        r.success = false;
        r.code = code;
        r.message = message;
        return r;
    }
}


